package com.tarena.lbs.marketing.web.controller;

import com.tarena.lbs.base.protocol.exception.BusinessException;
import com.tarena.lbs.base.protocol.model.Result;
import com.tarena.lbs.base.protocol.pager.PageResult;
import com.tarena.lbs.marketing.web.service.ActivityService;
import com.tarena.lbs.pojo.marketing.param.ActivityParam;
import com.tarena.lbs.pojo.marketing.query.ActivityQuery;
import com.tarena.lbs.pojo.marketing.vo.ActivityVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
public class ActivityController {
    @Autowired
    private ActivityService activityService;
    //后台管理活动 分页查询
    @PostMapping("/admin/marketing/marketingActivity/info/list")
    public Result<PageResult<ActivityVO>> pageList(@RequestBody ActivityQuery query)
        throws BusinessException{
        return new Result<>(activityService.pageList(query));
    }

    //后台互动管理 新增活动
    @PostMapping("/admin/marketing/marketingActivity/info/save")
    public Result<Void> save(@RequestBody ActivityParam param)
        throws BusinessException{
        activityService.save(param);
        return Result.success();
    }

    //根据活动的id查询活动详情
    @GetMapping("/admin/marketing/marketingActivity/info/detail/{id}")
    public Result<ActivityVO> detail(@PathVariable("id") Integer id){
        return new Result<>(activityService.detail(id));
    }
}
